{# **
 * Copyright since 2007 PrestaShop SA and Contributors
 * PrestaShop is an International Registered Trademark & Property of PrestaShop SA
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Open Software License (OSL 3.0)
 * that is bundled with this package in the file LICENSE.md.
 * It is also available through the world-wide-web at this URL:
 * https://opensource.org/licenses/OSL-3.0
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@prestashop.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade PrestaShop to newer
 * versions in the future. If you wish to customize PrestaShop for your
 * needs please refer to https://devdocs.prestashop.com/ for more information.
 *
 * @author    PrestaShop SA and Contributors <contact@prestashop.com>
 * @copyright Since 2007 PrestaShop SA and Contributors
 * @license   https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
 * #}
{% extends '@PrestaShop/Admin/layout.html.twig' %}

{% block content %}
  {{ include('@PrestaShop/Admin/Common/multistore-infotip.html.twig') }}

  {# Stable feature flags form #}
  {% if stableFeatureFlagsForm %}
    {{ form_start(stableFeatureFlagsForm, {attr: {class: 'form'}}) }}
    {% block stable_feature_flag_form %}
      <div class="card" id="configuration_fieldset_general">
        <h3 class="card-header">
          <i class="material-icons">settings</i>
          {{ 'New features'|trans({}, 'Admin.Advparameters.Feature') }}
        </h3>

        <div class="card-body">
          <div class="form-wrapper">
            <div class="alert alert-info alert-experimental" role="alert">
              {{ 'New features are available. Feel free to try them out!'|trans({}, 'Admin.Advparameters.Notification') }}
            </div>
            {{ form_widget(stableFeatureFlagsForm.feature_flags) }}
          </div>
        </div>
          <div class="card-footer">
            <div class="d-flex justify-content-end">
              {{ form_widget(stableFeatureFlagsForm.submit) }}
            </div>
          </div>
      </div>
    {% endblock %}
    {{ form_end(stableFeatureFlagsForm) }}
  {% endif %}

  {# Beta feature flags form #}
  {% if betaFeatureFlagsForm %}
    {{ form_start(betaFeatureFlagsForm, {attr: {class: 'form'}}) }}
    {% block beta_feature_flag_form %}
      <div class="card" id="configuration_fieldset_general">
        <h3 class="card-header">
          <i class="material-icons">settings</i>
          {{ 'Experimental features'|trans({}, 'Admin.Advparameters.Feature') }}
        </h3>

        <div class="card-body">
          <div class="form-wrapper">
            <div class="alert medium-alert alert-warning" role="alert">
              {{ 'Testing a feature before its official release can be exciting. However, you must be aware of the potential risks of such experiments:'|trans({}, 'Admin.Advparameters.Notification') }}
              <ul>
                <li>{{ 'Experimental features are still under development. Enabling them could therefore have unintended consequences and cause data loss.'|trans({}, 'Admin.Advparameters.Notification') }}</li>
                <li>{{ 'In any case, you should never experiment in production.'|trans({}, 'Admin.Advparameters.Notification') }}</li>
              </ul>
            </div>
            {{ form_widget(betaFeatureFlagsForm.feature_flags) }}
          </div>
        </div>
        <div class="card-footer">
          <div class="d-flex justify-content-end">
            {% set widgetVars = betaFeatureFlagsForm.submit.vars|merge({attr: {
              'data-modal-title': 'Are you sure you want to enable this experimental feature?'|trans({}, 'Admin.Advparameters.Notification'),
              'data-modal-message': 'You are about to enable a feature that is not stable yet. This should only be done in a test environment or in full knowledge of the potential risks.'|trans({}, 'Admin.Advparameters.Notification'),
              'data-modal-apply': 'Enable'|trans({}, 'Admin.Actions'),
              'data-modal-cancel': 'Cancel'|trans({}, 'Admin.Actions'),
            }}) %}
            {{ form_widget(betaFeatureFlagsForm.submit, widgetVars) }}
          </div>
        </div>
      </div>
    {% endblock %}
    {{ form_end(betaFeatureFlagsForm) }}
  {% endif %}
{% endblock %}

{% block javascripts %}
  {{ parent() }}

  <script src="{{ asset('themes/new-theme/public/feature_flag.bundle.js') }}"></script>
{% endblock %}
